//
//  SCHomeJFSCCell.m
//  shangcheng
//
//  Created by Jie Jie on 2019/6/17.
//  Copyright © 2019 张艳江. All rights reserved.
//

#import "SCHomeJFSCCell.h"

CGFloat const k_jfsc_tb_space = 10;



@interface  SCHomeJFSCCell()

@property (nonatomic , strong) UIImageView *jfsc_img_view;
@property (nonatomic , strong) UILabel *jfsc_name_label;
@property (nonatomic , strong) UIImageView *jfsc_price_img_view;
@property (nonatomic , strong) UILabel *jfsc_price_label;

@property (nonatomic , assign) CGRect jfsc_frame;

@end

@implementation SCHomeJFSCCell

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.jfsc_frame = frame;
    
        [self.contentView addSubview:self.jfsc_img_view];
        [self.contentView addSubview:self.jfsc_price_label];
        [self.contentView addSubview:self.jfsc_name_label];
        [self.contentView addSubview:self.jfsc_price_img_view];
        
        [self add_masonry];
        
    }
    return self;
}

-(void)add_masonry{
    
    CGFloat cell_w = self.jfsc_frame.size.width;
    CGFloat cell_h = self.jfsc_frame.size.height;
    CGFloat img_h = cell_w * 79/105;
    CGFloat label_h = (cell_h - img_h) /2.5;
    CGFloat price_label_h = 13;
    CGFloat price_label_y = (label_h - price_label_h) / 2;
    
    [self.jfsc_img_view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.and.top.mas_equalTo(0);
        make.height.mas_equalTo(img_h);
    }];
    
    [self.jfsc_name_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.mas_equalTo(0);
        make.top.mas_equalTo(self.jfsc_img_view.mas_bottom);
        make.height.mas_equalTo(label_h);
    }];
    
    [self.jfsc_price_img_view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
    make.top.mas_equalTo(self.jfsc_name_label.mas_bottom).mas_offset(price_label_y);
        make.height.and.width.mas_equalTo(price_label_h);
    }];
    
    [self.jfsc_price_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.jfsc_price_img_view.mas_right).mas_offset(5);
        make.top.mas_equalTo(self.jfsc_name_label.mas_bottom);
        make.height.mas_equalTo(label_h);
        make.right.mas_equalTo(0);
    }];
    
    
}

-(UIImageView *)jfsc_img_view{
    
    if (_jfsc_img_view == nil) {
        _jfsc_img_view = [[UIImageView alloc] init];
        _jfsc_img_view.layer.masksToBounds = YES;
        _jfsc_img_view.layer.cornerRadius = 3;
        _jfsc_img_view.backgroundColor = RGB(219, 52, 52);
    }
    return _jfsc_img_view;
}

-(UILabel *)jfsc_name_label{
    
    if (_jfsc_name_label == nil) {
        _jfsc_name_label = [[UILabel alloc] init];
        _jfsc_name_label.text = @"舒克牙膏";
        _jfsc_name_label.textAlignment = NSTextAlignmentLeft;
        _jfsc_name_label.font = [UIFont systemFontOfSize:11];
        _jfsc_name_label.textColor = RGB(102, 102, 102);
    }
    return _jfsc_name_label;
}

-(UIImageView *)jfsc_price_img_view{
    
    if (_jfsc_price_img_view == nil) {
        _jfsc_price_img_view = [[UIImageView alloc] init];
        _jfsc_price_img_view.image = [UIImage imageNamed:@"jfsc_icon_jif"];
    }
    return  _jfsc_price_img_view;
}

-(UILabel *)jfsc_price_label{
    
    if (_jfsc_price_label == nil) {
        _jfsc_price_label = [[UILabel alloc] init];
        _jfsc_price_label.textColor = RGB(219, 52, 52);
        _jfsc_price_label.font = [UIFont systemFontOfSize:12];
        _jfsc_price_label.textAlignment = NSTextAlignmentLeft;
        _jfsc_price_label.text = @"100";
    }
    return _jfsc_price_label;
}

@end
